#include<iostream>
#include<string>
#include<signal.h>
#include<unistd.h>
#include<stdio.h>
using namespace std;
void sighandler(int signal);
int main(int argc, char** argv)
{
    struct sigaction ac,ao;
    ac.sa_handler = sighandler;
    sigemptyset(&ac.sa_mask);
    ac.sa_flags = 0;
    sigaction(SIGINT, &ac, &ao); // save old action for SIGINT
    pause();
    return 0;
}

void sighandler(int signal)
{
    printf("received a signal:%d\n", signal);
    // do some cleanup work here
    return;
}